package abc.com.abc.activity;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

import java.io.File;
import java.net.URI;
import java.net.URL;

import abc.com.abc.R;

public class VideoActivity extends AppCompatActivity {
    private TextView dringOne ,dringTwo;
    private VideoView videoView;
    private MediaController controller;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_view);
        dringOne = findViewById(R.id.dringOne);
        dringTwo = findViewById(R.id.dringTwo);
        videoView = findViewById(R.id.video_view);
        controller = new MediaController(this);
        videoView.setMediaController(controller);

        File file = new File("/storage/emulated/0/Movies/abcone.3gp");
        file.getAbsolutePath();
        Log.i("test", "onCreate: 1111"+ file.getAbsolutePath());
        dringOne.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                play();
                Uri uri = Uri.parse("https://m.jsyks.com/n_d3e207");
                Intent intent = new Intent(Intent.ACTION_VIEW,uri);
                startActivity(intent);


            }
        });
        dringTwo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                play();

                Uri uri = Uri.parse("http://xcsp.jsyks.com/defa9d.htm");
                Intent intent = new Intent(Intent.ACTION_VIEW,uri);
                startActivity(intent);

            }
        });
    }

    private void play() {
        if (videoView != null && videoView.isPlaying()){
            videoView.stopPlayback();
            return;
        }
    }


}
